module.exports = app => {
    const { STRING, INTEGER, TEXT } = app.Sequelize;

    const TopicTeacher = app.model.define('topic-teacher', {
        topicId: {
            type: INTEGER,
            allowNull: false,
        },
        name: {
            type: STRING(255),
            allowNull: false,
        },
        avatar: {
            type: STRING(255),
            allowNull: false,
        },
        title: {
            type: STRING(255),
            allowNull: true,
        },
        desc: {
            type: TEXT('long'), // 'long'表示LONGTEXT，适用于存储大量文本
            allowNull: true,
        },
    }, {
        timestamps: true,
        underscored: false,
    });

    TopicTeacher.associate = function () {
        TopicTeacher.Topic = TopicTeacher.belongsTo(app.model.Topic, {
            foreignKey: "topicId",
            as: "topic"
        });
    };


    return TopicTeacher;
};
